class LazyImport(object):
    """
    动态导入模块
    """
    def __init__(self, module_name, module_class):
        """
        :param module_name:
        :param module_class:
        :return: 等同于 form module_name import module_class
        """
        self.module_name = module_name
        self.module_class = module_class
        self.module = None

    def __getattr__(self, name):
        if self.module is None:
            self.module = __import__(self.module_name, fromlist=[self.module_class])
        return getattr(self.module, name)
